All Questions
25 questions
6votes
3answers
333views
Implementation of arrays that store their size
In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
6votes
4answers
1kviews
Automate character search in C
THE TASK We are dealing with a string of symbols and need quick responses to queries of the following types: What is the position of the k-th occurrence of symbol X in the string? Reading from ...
4votes
2answers
2kviews
Linked list and array list performance comparison in C
After watching Stroustrup's presentation on performance comparison between vectors and linked lists (https://youtu.be/YQs6IC-vgmo?si=9r5wXqnwkmN29xqn), I've decided it would be a good problem to get a ...
1vote
2answers
458views
Simple snake game with C and raylib
Made a simple snake game using C and raylib for graphics, Would like to be critiqued on the clearity and efficiency of the code. ...
2votes
1answer
114views
Another generic dynamic arrays in C
Wrote this (and others not here) as an exercise to explore how generics could be implemented in C. Question -- if I were to support out-of-band error setting, how would that look like for ...
0votes
2answers
2kviews
6votes
2answers
158views
Another dynamic array implementation in C
I saw quite a few posts about making a dynamic array so I tried making my own for learning purposes. Here it is: ...
-1votes
2answers
109views
Remove duplicates from array and save it to another one [duplicate]
I have been tasked to make an array without duplicated values from another existing array. So I did it, but I want to know is there some other better way to do that. Example input/output ...
8votes
2answers
197views
Printing a 2-D array diagonally
The case scenario: A 2-D array is given: 1 3 6 10 15 2 5 9 14 19 4 8 13 18 22 7 12 17 21 24 11 16 20 23 25 and its size ...
4votes
2answers
224views
Sorting an array of numbers by descending frequency
Somebody asked me to create a code that orders unique numbers of an array according to their frequency, ie: {1,3,3,4,4,4,4,4,2,2,5,5,5,5} to ...
6votes
1answer
432views
Dynamic array implementation in C
I have implemented a dynamic array in C. I am a beginner in C so any constructive feedback about improving the implementation would be greatly appreciated. Header file for the implementation( ...
4votes
1answer
11kviews
Matrix multiplication using functions in C
This exercise surprised me a little bit. I did not expect that gcc (GCC 6.3.0 in the MinGW suite) would use the C11 standard by default, which I realised after I ...
4votes
2answers
2kviews
Dynamic array C implementation
I'm a C beginner. For a tiny personal project, I was in need of an "auto-growing" array and here it is the implementation. I'd like to get some feedback. At the end there is a test function called in ...
10votes
1answer
2kviews
Dynamic stack C implementation
I'm a C beginner. I'm studying and implementing some data structures. I'd like to get feedback. This is a stack implemented with an dynamic array. In main there ...
10votes
6answers
1kviews
Primitive String trimmer in C
I just picked up C and am following through The C programming language. I've previously got experience with a lot of 'higher'-level languages, so when I saw this exercise in the book: Write a ...